package com.ymatou.iapi.coupon.testcase;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.http.client.ClientProtocolException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.coupon.parameter.CheckCouponsBean;
import com.ymatou.iapi.coupon.parameter.CheckCouponsData;
import com.ymatou.iapi.coupon.parameter.ConversionCouponBean;
import com.ymatou.iapi.coupon.parameter.CouponInfo;
import com.ymatou.iapi.coupon.parameter.CouponProducts;
import com.ymatou.iapi.coupon.parameter.OrderInfo;
import com.ymatou.iapi.coupon.parameter.ProductInfo;
import com.ymatou.iapi.coupon.parameter.SellerOrderInfo;
import com.ymatou.iapi.coupon.parameter.ShoppingInfo;
import com.ymatou.iapi.coupon.service.CheckCouponsCall;
import com.ymatou.iapi.couponmanage.parameter.CreateBean;
import com.ymatou.iapi.couponmanage.parameter.CreateCouponBean;
import com.ymatou.iapi.couponmanage.parameter.SellerCreateBatchBean;
import com.ymatou.iapi.couponmanage.parameter.UpdateApplyProductsBean;
import com.ymatou.iapi.couponmanage.parameter.executeTaskBean;
import com.ymatou.iapi.couponmanage.service.CreateCall;
import com.ymatou.iapi.couponmanage.service.executeTaskCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.CouponCallService;
import com.ymttest.business.service.CouponServiceCallServiceV2;
import com.ymttest.business.service.CouponServiceMCallServiceV2;
import com.ymttest.database.model.coupon;
import com.ymttest.database.model.couponconversioncode;
import com.ymttest.database.model.couponbatch;
import com.ymttest.database.model.couponconversion;
import com.ymttest.database.model.couponsequence;
import com.ymttest.database.model.couponusecondition;
import com.ymttest.database.sqlwapper.couponWapper;
import com.ymttest.database.sqlwapper.couponbatchWapper;
import com.ymttest.database.sqlwapper.couponconversionWapper;
import com.ymttest.database.sqlwapper.couponconversioncodeWapper;
import com.ymttest.database.sqlwapper.couponsendsubtaskWapper;
import com.ymttest.database.sqlwapper.couponsequenceWapper;
import com.ymttest.database.sqlwapper.couponuseconditionWapper;
//import com.ymttest.database.sqlwapper.couponPrivateUserBoundWapper;
//import com.ymttest.database.sqlwapper.couponScenarioWapper;
//import com.ymttest.database.sqlwapper.couponSettingWapper;
//import com.ymttest.database.sqlwapper.couponWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;

/**
 * 下单优惠券检验 FreeMaker Template自动生成代码
 */  
@TestSuite
public class Ts_CheckCoupons {
	private static CheckCouponsBean checkcouponsBean;
	private static CheckCouponsCall checkcouponsCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("下单优惠券检验");
	}

	@Before
	public void caseUp() {
		checkcouponsBean = new CheckCouponsBean();
		checkcouponsCall = new CheckCouponsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(checkcouponsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_CheckCoupons_001() {
		Logger.start(true, "下单优惠券检验");
		try {
			CouponServiceCallServiceV2 couponseriveCallService = new CouponServiceCallServiceV2();

			int userId = Integer.parseInt(EnvSetup.getData("couponBuyerId"));
			ShoppingInfo shoppingInfo = couponseriveCallService.setDefaultShoppingInfo(userId, "164424663020321883X8oRcqOb",
					"160524663720321883XdVf4qhD");

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	
	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_CheckCoupons_003() {
		Logger.start(true, "下单优惠券检验-验证平台链接优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_CheckCoupons_004() {
		Logger.start(true, "下单优惠券检验-商家全场优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();	

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, null, couponBatchBean);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	@Ignore
	public void Tc_CheckCoupons_005() {
		Logger.start(true, "下单优惠券检验-商家商品优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();	

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();			

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, null, couponBatchBean);

			String couponcode = shoppingInfo.getSellerOrderInfos().get(0).getCouponCode();
			String productcode = shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos()
					.get(0).getProductCode();

			List<String> productCodes = new ArrayList<>();
			
			productCodes.add(productcode);
			coupon coupon = new couponWapper().selectBycouponCode(shoppingInfo.getSellerOrderInfos().get(0).getCouponCode()).get(0);

			UpdateApplyProductsBean updateApplyProductsBean = couponCallService.setUpdateApplyProductsBean(coupon.getBatchId(), productCodes);
			couponCallService.UpdateApplyProducts(updateApplyProductsBean);
			
			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_017() {
		Logger.start(true, "下单优惠券检验-平台链接优惠券-指定ProductCategories的商品能使用优惠券,JIRACONN-954");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			List<Integer> Categories = new ArrayList<Integer>();
			Categories.add(11111);
			Categories.add(22222);

			createcouponBean.setCategories(Categories);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			List<String> Categories2 = new ArrayList<String>();
			Categories2.add("22222");

			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductCategoryList(Categories2);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_018() {
		Logger.start(false, "下单优惠券检验-平台链接优惠券-非指定ProductCategories的商品不能使用优惠券,JIRACONN-954");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			List<Integer> Categories = new ArrayList<Integer>();
			Categories.add(33333);
			Categories.add(22222);

			createcouponBean.setCategories(Categories);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			List<String> Categories2 = new ArrayList<String>();
			Categories2.add("222223");

			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductCategoryList(Categories2);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("100113", checkcouponsCall.getStatusCode1(), "验证返回Code");
			Logger.verifyEquals("优惠券限制分类，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_019() {
		Logger.start(true, "下单优惠券检验-平台链接优惠券-指定SpecificProducts的商品能使用优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			List<Integer> list = new ArrayList<Integer>();
			int x = (int) (Math.random() * 100);
			int y = (int) (Math.random() * 100);

			list.add(x);
			list.add(y);


			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			List<String> productCodes = new ArrayList<>();
			
			productCodes.add("Abc1233");
			productCodes.add("bgg224");

			createcouponBean.setProductIds(productCodes);
			
			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_020() {
		Logger.start(false, "下单优惠券检验-平台链接优惠券-非指定SpecificProducts的商品不能使用优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			List<String> productCodes = new ArrayList<>();
			
			productCodes.add("Abc1233");
			productCodes.add("bgg224");
			
			createcouponBean.setProductIds(productCodes);
			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			coupon coupon = new couponWapper().selectBycouponCode(shoppingInfo.getPlatformCouponCode()).get(0);
				
			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("100111", checkcouponsCall.getStatusCode1(), "验证返回Code");
			Logger.verifyEquals("优惠券限制商品，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_021() {
		Logger.start(true, "下单优惠券检验-平台链接优惠券-指定ProductBrands的商品能使用优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			List<Integer> list = new ArrayList<Integer>();
			int x = (int) (Math.random() * 10000);
			int y = (int) (Math.random() * 10000);

			list.add(x);
			list.add(y);

			createcouponBean.setBrands(list);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0).setBrandId(x);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_023() {
		Logger.start(true, "下单优惠券检验-平台链接优惠券-指定ActivityIds的商品能使用优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			List<Integer> list = new ArrayList<Integer>();
			int x = (int) (Math.random() * 10000);
			int y = (int) (Math.random() * 10000);

			list.add(x);
			list.add(y);

			createcouponBean.setActivityIds(list);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0).setActivityId(x);
			;

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_024() {
		Logger.start(false, "下单优惠券检验-平台链接优惠券-非指定ActivityIds的商品不能使用优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			List<Integer> list = new ArrayList<Integer>();
			int x = (int) (Math.random() * 10000);
			int y = (int) (Math.random() * 10000);

			list.add(x);
			list.add(y);

			createcouponBean.setActivityIds(list);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("100112", checkcouponsCall.getStatusCode1(), "验证返回Code");
			Logger.verifyEquals("优惠券限制活动，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_025() {
		Logger.start(true, "下单优惠券检验-平台链接优惠券-指定UsePlatforms的商品能使用优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			List<Integer> list = new ArrayList<Integer>();
			int x = (int) (Math.random() * 100);
			int y = (int) (Math.random() * 100);

			list.add(x);
			list.add(y);

			createcouponBean.setUsePlatforms(list);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			shoppingInfo.setPlatformUsage(x);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_026() {
		Logger.start(false, "下单优惠券检验-平台链接优惠券-非指定UsePlatforms的商品不能使用优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();

			List<Integer> list = new ArrayList<Integer>();
			int x = (int) (Math.random() * 100);
			int y = (int) (Math.random() * 100);

			list.add(x);
			list.add(y);

			createcouponBean.setUsePlatforms(list);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("100110", checkcouponsCall.getStatusCode1(), "验证返回Code");
			Logger.verifyEquals("优惠券限制平台，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_033() {
		Logger.start(true, "下单优惠券检验-全场链接优惠券-优惠券使用订单金额按所有订单中（跨买手）所有商品总金额计算，不减商品优惠券金额-金额满足要求");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			createcouponBean.getCouponValues().get(0).setOrderMinAmount(new BigDecimal(4000));

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			// 在原来基础上增加一个买手两个商品
			SellerOrderInfo sellerOrderInfo = generateSellerOrderInfoBean();

			shoppingInfo.getSellerOrderInfos().add(sellerOrderInfo);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回products
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_034() {
		Logger.start(false, "下单优惠券检验-全场链接优惠券-优惠券使用订单金额按所有订单中（跨买手）所有商品总金额计算，不减商品优惠券金额-金额不满足要求");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		
			createcouponBean.getCouponValues().get(0).setOrderMinAmount(new BigDecimal(4001));

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			// 在原来基础上增加一个买手两个商品
			SellerOrderInfo sellerOrderInfo = generateSellerOrderInfoBean();

			shoppingInfo.getSellerOrderInfos().add(sellerOrderInfo);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("0", checkcouponsCall.getSellerId(), "验证返回Code");
			Logger.verifyEquals("100116", checkcouponsCall.getStatusCode1(), "验证返回Code");
			Logger.verifyEquals("商品金额不足，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_035() {
		Logger.start(true, "下单优惠券检验-全场链接优惠券+商家优惠券-优惠券使用订单金额按所有订单中（跨买手）所有商品总金额计算，不减商品优惠券金额-金额满足要求");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();	

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			
			couponBatchBean.setCouponAmount(new BigDecimal(100));
			couponBatchBean.setOrderMinAmount(new BigDecimal(1000));

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			createcouponBean.getCouponValues().get(0).setOrderMinAmount(new BigDecimal(4000));

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, couponBatchBean);

			// 在原来基础上增加一个买手两个商品
			SellerOrderInfo sellerOrderInfo = generateSellerOrderInfoBean();

			shoppingInfo.getSellerOrderInfos().add(sellerOrderInfo);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证商家优惠券对应商品信息
			String couponCode = shoppingInfo.getSellerOrderInfos().get(0).getCouponCode();

			verifyProductInfo(shoppingInfo.getProductsByCouponCode(couponCode),
					checkcouponsCall.getData().getProductsByCouponCode(couponCode));

			// 验证平台优惠券对应商品信息
			String platformCouponCode = shoppingInfo.getPlatformCouponCode();

			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getProductsByCouponCode(platformCouponCode));

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_036() {
		Logger.start(false, "下单优惠券检验-全场链接优惠券+商家优惠券-优惠券使用订单金额按所有订单中（跨买手）所有商品总金额计算，不减商品优惠券金额-金额不满足要求");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();	

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			
			couponBatchBean.setCouponAmount(new BigDecimal(100));
			couponBatchBean.setOrderMinAmount(new BigDecimal(1000));

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			createcouponBean.getCouponValues().get(0).setOrderMinAmount(new BigDecimal(4100));

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, couponBatchBean);

			// 在原来基础上增加一个买手两个商品
			SellerOrderInfo sellerOrderInfo = generateSellerOrderInfoBean();

			shoppingInfo.getSellerOrderInfos().add(sellerOrderInfo);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("0", checkcouponsCall.getSellerId(), "验证返回Code");
			Logger.verifyEquals("100116", checkcouponsCall.getStatusCode1(), "验证返回Code");
			Logger.verifyEquals("商品金额不足，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_037() {
		Logger.start(true, "下单优惠券检验-商家全场优惠券-优惠券使用订单金额按该商家所有商品总金额计算-金额满足条件");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();	

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			
			couponBatchBean.setCouponAmount(new BigDecimal(100));
			couponBatchBean.setOrderMinAmount(new BigDecimal(4000));

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, null, couponBatchBean);

			// 在原来基础上增加该商家订单信息
			SellerOrderInfo sellerOrderInfo = generateSellerOrderInfoBean();

			List<OrderInfo> OrderInfos = sellerOrderInfo.getOrderInfos();

			for (OrderInfo orderInfo : OrderInfos) {
				shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().add(orderInfo);
			}

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回products
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_038() {
		Logger.start(true, "下单优惠券检验-商家全场优惠券-优惠券使用订单金额按该商家所有商品总金额计算-金额不满足条件");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();	

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			
			couponBatchBean.setCouponAmount(new BigDecimal(100));
			couponBatchBean.setOrderMinAmount(new BigDecimal(4001));

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, null, couponBatchBean);

			// 在原来基础上增加该商家订单信息
			SellerOrderInfo sellerOrderInfo = generateSellerOrderInfoBean();

			List<OrderInfo> OrderInfos = sellerOrderInfo.getOrderInfos();

			for (OrderInfo orderInfo : OrderInfos) {
				shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().add(orderInfo);
			}

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals(shoppingInfo.getSellerOrderInfos().get(0).getSellerId(),
					Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回Code");
			Logger.verifyEquals("100116", checkcouponsCall.getStatusCode1(), "验证返回Code");
			Logger.verifyEquals("商品金额不足，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_039() {
		Logger.start(true, "下单优惠券检验-商家全场优惠券-优惠券使用订单金额按该商家所有商品总金额计算-该商家商品金额不满足条件，验证其他商家商品金额不会计算进去");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();	

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			
			couponBatchBean.setCouponAmount(new BigDecimal(100));
			couponBatchBean.setOrderMinAmount(new BigDecimal(3000));

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, null, couponBatchBean);

			// 在原来基础上增加一个买手两个商品
			SellerOrderInfo sellerOrderInfo = generateSellerOrderInfoBean();

			shoppingInfo.getSellerOrderInfos().add(sellerOrderInfo);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals(shoppingInfo.getSellerOrderInfos().get(0).getSellerId(),
					Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回Code");
			Logger.verifyEquals("100116", checkcouponsCall.getStatusCode1(), "验证返回Code");
			Logger.verifyEquals("商品金额不足，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_044() {
		Logger.start(true, "下单优惠券检验-验证平台链接优惠券-优惠券已经作废-已经领取的还是可以用的");
		try {

			int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();
			List<couponbatch> couponbatchs = new couponbatchWapper().selectBybatchCode(batchcode2);

			String platformcouponCode = couponCallService.receiveCouponInfo(couponbatchs.get(0).getBatchCode(),
					userId).getUserReceiveResult().getCouponCode();

			ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformcouponCode, null);

			// 作废批次
			couponCallService.InvalidPlatformBatch(batchcode2,"wwerwre","ewrwerew");

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_045() {
		Logger.start(false, "下单优惠券检验-商家全场优惠券-优惠券已经作废");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
			int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			
			String sellerCouponCode = null;

			String batchCode1 = couponCallService.SellerCreateBatch(couponBatchBean).getBatchCode();
			sellerCouponCode = couponCallService.receiveCouponInfo(batchCode1, userId).getUserReceiveResult().getCouponCode();
			ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, couponBatchBean.getSellerId(),null, sellerCouponCode);

			// 作废批次
			couponCallService.InvalidSellerBatch(couponBatchBean.getSellerId(),batchCode1);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_048() {
		Logger.start(false, "下单优惠券检验-验证平台链接优惠券-优惠券已经过期");
		try {

			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
			int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));

			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();
		
			String platformCouponCode = couponCallService.receiveCouponInfo(batchcode2, userId).getUserReceiveResult().getCouponCode();

			Date date = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);
			new couponWapper().setValidEndByCouponCode(platformCouponCode,date);

			ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformCouponCode, null);
			
			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("0", checkcouponsCall.getSellerId(), "验证返回SellerId");
			Logger.verifyEquals("100106", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("优惠券已过期", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_049() {
		Logger.start(false, "下单优惠券检验-商家全场优惠券-优惠券已经过期");
		try {
			// 买家
			int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
			
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();	

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();

			String batchCode1 = couponCallService.SellerCreateBatch(couponBatchBean).getBatchCode();
			String couponCode = couponCallService.receiveCouponInfo(batchCode1, userId).getUserReceiveResult().getCouponCode();

			Date date = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);

			new couponWapper().setValidEndByCouponCode(couponCode,date);

			ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, couponBatchBean.getSellerId(),null, couponCode);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals( couponBatchBean.getSellerId(), Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回SellerId");
			Logger.verifyEquals("100106", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("优惠券已过期", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_052() {
		Logger.start(false, "下单优惠券检验-验证平台链接优惠券-优惠券有效期还未开始");
		try {

			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
			int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));

			// 平台优惠券-链接
			String platformCouponCode;

			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	

			String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();

			platformCouponCode = couponCallService.receiveCouponInfo(batchcode2, userId).getUserReceiveResult().getCouponCode();

			Date date = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);
			new couponWapper().setValidStartByCouponCode(platformCouponCode,date);

			ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformCouponCode, null);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("0", checkcouponsCall.getSellerId(), "验证返回SellerId");
			Logger.verifyEquals("100107", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("优惠券还未生效", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_053() {
		Logger.start(false, "下单优惠券检验-商家全场优惠券-优惠券有效期还未开始");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
			// 买家
			int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
			// 卖家Id
			int sellerId = Integer.parseInt(EnvSetup.getData("SellerId"));

			// 商家优惠券
			String couponCode;

			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();

			String batchCode1 = couponCallService.SellerCreateBatch(couponBatchBean).getBatchCode();
			couponCode = couponCallService.receiveCouponInfo(batchCode1, userId).getUserReceiveResult().getCouponCode();

			Date date = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);
			new couponWapper().setValidStartByCouponCode(couponCode,date);

			ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, couponBatchBean.getSellerId(), null, couponCode);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals( couponBatchBean.getSellerId(), Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回SellerId");
			Logger.verifyEquals("100107", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("优惠券还未生效", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_060() {
		Logger.start(true, "下单优惠券检验-验证平台链接优惠券-优惠券仅允许新用户使用-新用户");
		try {
			int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));

			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		


			String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();

			String platformCouponCode = couponCallService.receiveCouponInfo(batchcode2, userId).getUserReceiveResult().getCouponCode();

			List<Map> maps = new couponWapper().selectCouponInfoByCouponCode(platformCouponCode);

			Map map = maps.get(0);
			int batchid = Integer.parseInt(map.get("BatchId").toString());

			// 优惠券设置为只允许新用户领取
			//new couponScenarioWapper().setiUserType(1, iCouponScenarioId);
			new couponbatchWapper().setReceiveUserType(1, batchid);

			ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformCouponCode, null);

			// 设置为新用户
			shoppingInfo.getBuyerInfo().setBuyerOrderNum(0);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("null", checkcouponsCall.getSellerId(), "验证返回SellerId");
			Logger.verifyEquals("0", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("操作成功！", checkcouponsCall.getMessage(), "验证返回Message");

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	@Ignore
	public void Tc_CheckCoupons_061() {
		Logger.start(true, "下单优惠券检验-验证平台链接优惠券-优惠券仅允许新用户使用-老用户-该限制已取消(跟用户没有关系，只要领取了券就可以使用)");
		try {
			int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));

			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		
			createcouponBean.setUserType(1);
			
			String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();

			String platformCouponCode = couponCallService.receiveCouponInfo(batchcode2, userId,0).getUserReceiveResult().getCouponCode();

			ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformCouponCode, null);

			// 设置为老用户
			shoppingInfo.getBuyerInfo().setBuyerOrderNum(10);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("0", checkcouponsCall.getSellerId(), "验证返回SellerId");
			Logger.verifyEquals("100108", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("优惠券仅限新用户使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	@Ignore
	public void Tc_CheckCoupons_062() {
		Logger.start(true, "下单优惠券检验-验证平台链接优惠券-优惠券仅允许老用户使用-新用户-该限制已取消(跟用户没有关系，只要领取了券就可以使用)");
		try {
			int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		
			createcouponBean.setUserType(2);
			
			String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();

			String platformCouponCode = couponCallService.receiveCouponInfo(batchcode2, userId,10).getUserReceiveResult().getCouponCode();

			ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformCouponCode, null);

			// 设置为新用户
			shoppingInfo.getBuyerInfo().setBuyerOrderNum(0);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("0", checkcouponsCall.getSellerId(), "验证返回SellerId");
			Logger.verifyEquals("100109", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("优惠券仅限老用户使用", checkcouponsCall.getMessage(), "验证返回Message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_063() {
		Logger.start(true, "下单优惠券检验-验证平台链接优惠券-优惠券仅允许老用户使用-老用户");
		try {
			int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));

			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		
			createcouponBean.setUserType(2);

			String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();

			String platformCouponCode = couponCallService.receiveCouponInfo(batchcode2, userId,10).getUserReceiveResult().getCouponCode();

			ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformCouponCode, null);

			// 设置为老用户
			shoppingInfo.getBuyerInfo().setBuyerOrderNum(10);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("null", checkcouponsCall.getSellerId(), "验证返回SellerId");
			Logger.verifyEquals("0", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("操作成功！", checkcouponsCall.getMessage(), "验证返回Message");

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_065() {
		Logger.start(false, "下单优惠券检验-验证平台链接优惠券-优惠券不属于当前用户");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			int sellerId = Integer.parseInt(EnvSetup.getData("customerId"));
			shoppingInfo.getBuyerInfo().setBuyerId(sellerId);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("0", checkcouponsCall.getSellerId(), "验证返回SellerId");
			Logger.verifyEquals("100100", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("优惠券不存在", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_066() {
		Logger.start(false, "下单优惠券检验-商家全场优惠券-优惠券不属于当前用户");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();	

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, null, couponBatchBean);

			int sellerId = Integer.parseInt(EnvSetup.getData("customerId"));
			shoppingInfo.getBuyerInfo().setBuyerId(sellerId);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals(shoppingInfo.getSellerOrderInfos().get(0).getSellerId(),
					Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回SellerId");
			Logger.verifyEquals("100100", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("优惠券不存在", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_CheckCoupons_068() {
		Logger.start(false, "下单优惠券检验-验证平台链接优惠券-优惠券超出批次最大使用次数-该限制已取消");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			String couponCode = shoppingInfo.getPlatformCouponCode();
//			int iCouponSettingId = new couponWapper().selectBycouponCode(couponCode).get(0).getiCouponSetting();
//			new couponSettingWapper().setiMaxUseTime(iCouponSettingId, 0);
			
			int batchId = new couponWapper().selectBycouponCode(couponCode).get(0).getBatchId();
			new couponbatchWapper().setMaxUseTime(0, batchId);
			
			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("0", checkcouponsCall.getSellerId(), "验证返回SellerId");
			Logger.verifyEquals("100118", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("超出批次最大使用次数", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

//	@Test
//	@Category({ P2.class })
//	@TestCase
//	@Ignore
//	public void Tc_CheckCoupons_069() {
//		Logger.start(false, "下单优惠券检验-商家全场优惠券-优惠券超出批次最大使用次数-该限制已取消");
//		try {
//			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();	
//
//			// 商家优惠券
//			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
//			
//			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, null, couponBatchBean);
//
//			String couponCode = shoppingInfo.getSellerOrderInfos().get(0).getCouponCode();
////			int iCouponSettingId = new couponWapper().selectBycouponCode(couponCode).get(0).getiCouponSetting();
////			new couponSettingWapper().setiMaxUseTime(iCouponSettingId, 0);
//			int batchId = new couponWapper().selectBycouponCode(couponCode).get(0).getBatchId();
//			new couponbatchWapper().setMaxUseTime(0, batchId);
//
//			checkcouponsBean.setShoppingInfo(shoppingInfo);
//			checkcouponsCall.setData(checkcouponsBean);
//			checkcouponsCall.callService();
//
//			Logger.verifyEquals(shoppingInfo.getSellerOrderInfos().get(0).getSellerId(),
//					Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回SellerId");
//			Logger.verifyEquals("100118", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
//			Logger.verifyEquals("超出批次最大使用次数", checkcouponsCall.getMessage(), "验证返回Message");
//
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
//
//	@Test
//	@Category({ P2.class })
//	@TestCase
//   @Ignore
//	public void Tc_CheckCoupons_071() {
//		Logger.start(false, "下单优惠券检验-验证平台短码+商家全场优惠券-平台链接优惠券超出批次最大使用次数-该限制已取消");
//		try {
//			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
//
//			// 平台优惠券
//			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		
//
//			// 商家优惠券
//			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
//			
//			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, couponBatchBean);
//
//			String couponCode = shoppingInfo.getPlatformCouponCode();
//			int iCouponSettingId = new couponWapper().selectBycouponCode(couponCode).get(0).getiCouponSetting();
//			new couponSettingWapper().setiMaxUseTime(iCouponSettingId, 0);
//			
//			int batchId = new couponWapper().selectBycouponCode(couponCode).get(0).getBatchId();
//			new couponbatchWapper().setMaxUseTime(0, batchId);
//
//			checkcouponsBean.setShoppingInfo(shoppingInfo);
//			checkcouponsCall.setData(checkcouponsBean);
//			checkcouponsCall.callService();
//
//			Logger.verifyEquals("0", checkcouponsCall.getSellerId(), "验证返回SellerId");
//			Logger.verifyEquals("100118", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
//			Logger.verifyEquals("超出批次最大使用次数", checkcouponsCall.getMessage(), "验证返回Message");
//
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
//
//	@Test
//	@Category({ P1.class })
//	@TestCase
//	@Ignore
//	public void Tc_CheckCoupons_074() {
//		Logger.start(false, "下单优惠券检验-验证平台链接优惠券-超出单张优惠券最大使用次数-该限制已取消");
//		try {
//			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
//
//			// 平台优惠券
//			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		
//
//			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);
//
//			String couponCode = shoppingInfo.getPlatformCouponCode();
//			new couponPrivateUserBoundWapper().UpdateiCouponUsedCount(couponCode, 0);
//			
//			
//			checkcouponsBean.setShoppingInfo(shoppingInfo);
//			checkcouponsCall.setData(checkcouponsBean);
//			checkcouponsCall.callService();
//
//			Logger.verifyEquals("0", checkcouponsCall.getSellerId(), "验证返回SellerId");
//			Logger.verifyEquals("100119", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
//			Logger.verifyEquals("超出单张优惠券最大使用次数", checkcouponsCall.getMessage(), "验证返回Message");
//
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
//
//	@Test
//	@Category({ P1.class })
//	@TestCase
//	@Ignore
//	public void Tc_CheckCoupons_075() {
//		Logger.start(false, "下单优惠券检验-商家全场优惠券-超出单张优惠券最大使用次数-该限制已取消");
//		try {
//			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
//
//			// 商家优惠券
//			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
//
//			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, null, couponBatchBean);
//
//			String couponCode = shoppingInfo.getSellerOrderInfos().get(0).getCouponCode();
//			int iCouponSettingId = new couponWapper().selectBycouponCode(couponCode).get(0).getiCouponSetting();
//			new couponPrivateUserBoundWapper().UpdateiCouponUsedCount(couponCode, 0);
//			new couponSettingWapper().setiMaxUseTime(iCouponSettingId, 0);
//
//			checkcouponsBean.setShoppingInfo(shoppingInfo);
//			checkcouponsCall.setData(checkcouponsBean);
//			checkcouponsCall.callService();
//
//			Logger.verifyEquals(shoppingInfo.getSellerOrderInfos().get(0).getSellerId(),
//					Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回SellerId");
//			Logger.verifyEquals("100118", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
//			Logger.verifyEquals("超出批次最大使用次数", checkcouponsCall.getMessage(), "验证返回Message");
//
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
//
//	@Test
//	@Category({ P3.class })
//	@TestCase
//	@Ignore
//	public void Tc_CheckCoupons_076() {
//		Logger.start(true, "下单优惠券检验-验证平台+商家全场优惠券-平台优惠券超出单张优惠券最大使用次数-该限制已取消");
//		try {
//			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
//
//			// 平台优惠券
//			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();			
//
//			// 商家优惠券
//			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
//
//			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, couponBatchBean);
//
//			String couponCode = shoppingInfo.getPlatformCouponCode();
//			int iCouponSettingId = new couponWapper().selectBycouponCode(couponCode).get(0).getiCouponSetting();
//			new couponPrivateUserBoundWapper().UpdateiCouponUsedCount(couponCode, 0);
//
//			checkcouponsBean.setShoppingInfo(shoppingInfo);
//			checkcouponsCall.setData(checkcouponsBean);
//			checkcouponsCall.callService();
//
//			Logger.verifyEquals("0", checkcouponsCall.getSellerId(), "验证返回SellerId");
//			Logger.verifyEquals("100119", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
//			Logger.verifyEquals("超出单张优惠券最大使用次数", checkcouponsCall.getMessage(), "验证返回Message");
//
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_083() {
		Logger.start(true, "下单优惠券检验-当购物车中所有商品都指定不允许使用优惠券，则需返回错误代码：100122-链接-针对wap的单商品");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			
			createcouponBean.setPerCouponMaxUseCount(1);
			createcouponBean.setPerUserReceiveMaxCount(1);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setIsNotAllowUsePlatformCoupon(true);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("0", checkcouponsCall.getSellerId(), "验证返回SellerId");
			Logger.verifyEquals("100122", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("商品活动指定不允许使用优惠券", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_084() {
		Logger.start(true, "下单优惠券检验-当购物车中所有商品都指定不允许使用优惠券，则需返回错误代码：100122-商家优惠券-针对wap的单商品");
		try {

			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();	

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			
			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, null, couponBatchBean);
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setIsNotAllowUseSellerCoupon(true);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals(shoppingInfo.getSellerOrderInfos().get(0).getSellerId(),
					Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回SellerId");
			Logger.verifyEquals("100122", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("商品活动指定不允许使用优惠券", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_085() {
		Logger.start(true, "下单优惠券检验-当购物车中所有商品都指定不允许使用优惠券，则需返回错误代码：100122-短码+商家优惠券-针对wap的单商品");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForConversion();
			
			createcouponBean.setPerCouponMaxUseCount(1);
			createcouponBean.setPerUserReceiveMaxCount(1);

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			

			ShoppingInfo shoppingInfo = setCheckCouponsBean(true, createcouponBean, couponBatchBean);

			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setIsNotAllowUseSellerCoupon(true);
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setIsNotAllowUsePlatformCoupon(true);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals(shoppingInfo.getSellerOrderInfos().get(0).getSellerId(),
					Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回SellerId");
			Logger.verifyEquals("100122", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("商品活动指定不允许使用优惠券", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_086() {
		Logger.start(true, "下单优惠券检验-当购物车中所有商品都指定不允许使用优惠券，则需返回错误代码：100122-链接+商家优惠券-针对wap的单商品");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			
			createcouponBean.setPerCouponMaxUseCount(1);
			createcouponBean.setPerUserReceiveMaxCount(1);

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, couponBatchBean);
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setIsNotAllowUseSellerCoupon(true);
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setIsNotAllowUsePlatformCoupon(true);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals(shoppingInfo.getSellerOrderInfos().get(0).getSellerId(),
					Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回SellerId");
			Logger.verifyEquals("100122", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("商品活动指定不允许使用优惠券", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_059() {
		Logger.start(true, "下单优惠券检验-平台短码优惠券-优惠券指定ActivityId时，全部商品满足，校验金额满足条件");
		try {

			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForConversion();
			
			createcouponBean.getCouponValues().get(0).setDeductionMaxAmount(new BigDecimal(100));
			createcouponBean.getCouponValues().get(0).setOrderMinAmount(new BigDecimal(4000));

			List<Integer> list = new ArrayList<Integer>();
			int x = (int) (Math.random() * 100);
			int y = (int) (Math.random() * 100);

			list.add(x);
			list.add(y);

			createcouponBean.setActivityIds(list);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(true, createcouponBean, null);

			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0).setActivityId(y);

			SellerOrderInfo sellerOrderInfo = generateSellerOrderInfoBean();
			List<OrderInfo> orderInfos = sellerOrderInfo.getOrderInfos();

			for (OrderInfo orderInfo : orderInfos) {
				List<ProductInfo> productInfos = orderInfo.getProductInfos();

				for (ProductInfo productInfo : productInfos) {
					productInfo.setActivityId(x);
				}
			}

			shoppingInfo.getSellerOrderInfos().add(sellerOrderInfo);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_087() {
		Logger.start(true, "下单优惠券检验-优惠券金额校验需要减去商品满减促销后的金额-RA-2339-平台短码优惠券金额符合条件");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForConversion();
			
			ShoppingInfo shoppingInfo = setCheckCouponsBean(true, createcouponBean, null);

			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductDiscountAmount(new BigDecimal(100));
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductPrice(new BigDecimal(300));

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_088() {
		Logger.start(true, "下单优惠券检验-优惠券金额校验需要减去商品满减促销后的金额-RA-2339-平台短码优惠券金额不符合条件");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForConversion();
			
			ShoppingInfo shoppingInfo = setCheckCouponsBean(true, createcouponBean, null);
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductDiscountAmount(new BigDecimal(100));
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductPrice(new BigDecimal(299));

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals(0, Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回SellerId");
			Logger.verifyEquals("100116", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("商品金额不足，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_089() {
		Logger.start(true, "下单优惠券检验-优惠券金额校验需要减去商品满减促销后的金额-RA-2339-平台链接优惠券金额符合条件");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			
			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductDiscountAmount(new BigDecimal(100));
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductPrice(new BigDecimal(300));

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_090() {
		Logger.start(true, "下单优惠券检验-优惠券金额校验需要减去商品满减促销后的金额-RA-2339-平台链接优惠券金额不符合条件");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			
			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductDiscountAmount(new BigDecimal(100));
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductPrice(new BigDecimal(299));

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals(0, Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回SellerId");
			Logger.verifyEquals("100116", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("商品金额不足，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_091() {
		Logger.start(true, "下单优惠券检验-优惠券金额校验需要减去商品满减促销后的金额-RA-2339-商家优惠券金额符合条件");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			
			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, null, couponBatchBean);
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductDiscountAmount(new BigDecimal(1));
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductPrice(new BigDecimal(3));

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_092() {
		Logger.start(true, "下单优惠券检验-优惠券金额校验需要减去商品满减促销后的金额-RA-2339-商家优惠券金额不符合条件");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
			
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();				
			
			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, null, couponBatchBean);
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductDiscountAmount(new BigDecimal(2));
			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setProductPrice(new BigDecimal(3));

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals(shoppingInfo.getSellerOrderInfos().get(0).getSellerId(),
					Integer.parseInt(checkcouponsCall.getSellerId()), "验证返回SellerId");
			Logger.verifyEquals("100116", checkcouponsCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("商品金额不足，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_094() {
		Logger.start(true, "下单优惠券检验-平台短码优惠券-指定Countrys的商品能使用优惠券,JIRACONN-3004");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForConversion();
			
			List<Integer> country1 = new ArrayList<Integer>();
			country1.add(11111);
			country1.add(22222);

			createcouponBean.setCountrys(country1);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(true, createcouponBean, null);

			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setCountryId(11111);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_CheckCoupons_095() {
		Logger.start(false, "下单优惠券检验-平台短码优惠券-非指定Countrys的商品不能使用优惠券,JIRACONN-3004");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForConversion();
			
			List<Integer> country1 = new ArrayList<Integer>();
			country1.add(11111);
			country1.add(22222);

			createcouponBean.setCountrys(country1);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(true, createcouponBean, null);

			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setCategoryId(11111);

			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setCountryId(33333);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("100123", checkcouponsCall.getStatusCode1(), "验证返回Code");
			Logger.verifyEquals("优惠券限制国家，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_096() {
		Logger.start(true, "下单优惠券检验-平台链接优惠券-指定CountryId的商品能使用优惠券-JIRACONN-3004");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			
			List<Integer> country1 = new ArrayList<Integer>();
			country1.add(11111);
			country1.add(22222);

			createcouponBean.setCountrys(country1);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setCountryId(11111);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_097() {
		Logger.start(false, "下单优惠券检验-平台链接优惠券-非指定CountryId的商品不能使用优惠券-JIRACONN-3004");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();

			List<Integer> country1 = new ArrayList<Integer>();
			country1.add(11111);
			country1.add(22222);

			createcouponBean.setCountrys(country1);

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
					.setCountryId(33333);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("100123", checkcouponsCall.getStatusCode1(), "验证返回Code");
			Logger.verifyEquals("优惠券限制国家，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_098() {
		Logger.start(false, "下单优惠券检验-平台链接优惠券-优先商品-优选优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setIsLimitPspProduct(true);   
			
			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);
	        shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0).setIsPsp(true);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_099() {
		Logger.start(false, "下单优惠券检验-平台链接优惠券-普通商品-优选优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setIsLimitPspProduct(true);   
			
			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("100124", checkcouponsCall.getStatusCode1(), "验证返回Code");
			Logger.verifyEquals("优惠券限制PSP商品，不允许使用", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CheckCoupons_100() {
		Logger.start(false, "下单优惠券检验-平台链接优惠券-优先商品-普通优惠券");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			
			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, createcouponBean, null);
	        shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0).setIsPsp(true);

			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			verifyReturn();

			// 验证返回商品
			verifyProductInfo(shoppingInfo.getAllProducts(),
					checkcouponsCall.getData().getCouponProductsList().get(0).getProducts());
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_CheckCoupons_101() {
		Logger.start(true, "下单优惠券检验-商家全场优惠券-券是其他商家");
		try {
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();	

			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();

			ShoppingInfo shoppingInfo = setCheckCouponsBean(false, null, couponBatchBean);
			shoppingInfo.getSellerOrderInfos().get(0).setSellerId(4456);
			checkcouponsBean.setShoppingInfo(shoppingInfo);
			checkcouponsCall.setData(checkcouponsBean);
			checkcouponsCall.callService();

			Logger.verifyEquals("不是商家发放的优惠券", checkcouponsCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	private ShoppingInfo setCheckCouponsBean(Boolean isShortCode, CreateCouponBean createcouponBean,
			SellerCreateBatchBean couponBatchBean) throws ClientProtocolException, IOException, InterruptedException {
		
		int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
		CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
		CouponServiceCallServiceV2 CouponServiceCallServiceV2 = new CouponServiceCallServiceV2();
		ShoppingInfo shoppingInfo ;
		
		// 平台优惠券
		String platformcouponCode = null;
		if (createcouponBean != null) {
			// createcouponBean
			String batchcode2 = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean).getBatchCode();
			List<couponbatch> couponbatchs = new couponbatchWapper().selectBybatchCode(batchcode2);

			if (isShortCode) {
				List<String> batchCodes = new ArrayList<>();
				batchCodes.add(batchcode2);

				CreateBean createBean = CouponServiceMCallServiceV2.setDefaultRandomCreateBean(batchCodes);
				CreateCall createCall = CouponServiceMCallServiceV2.create(createBean);
			
				// 等待兑换码生成
//				couponconversion bill = new couponconversionWapper()
//						.selectByBillName(createBean.getBillName()).get(0);
//				List<couponconversioncode> CouponConversionCodes = new couponconversioncodeWapper().selectByConversionId(bill.getConversionId());
//				
//				int flag=0;
//				while(CouponConversionCodes.size()<createBean.getGenerateQuantity() && flag<500)
//				{
//					flag++;
//					Thread.sleep(200);
//					CouponConversionCodes = new couponconversioncodeWapper().selectByConversionId(bill.getConversionId());	
//				}
				
				List<Map>  tasks=new couponsendsubtaskWapper().selectTaskByTaskTypelimit(3,1);
				executeTaskCall call=new executeTaskCall();
				executeTaskBean bean=new executeTaskBean();
				
				for(int i=0;i<tasks.size();i++){
					bean.setSubTaskId(Integer.parseInt(tasks.get(i).get("SubTaskId").toString()));
					call.setData(bean);
					call.callService();
				}
				couponconversion bill = new couponconversionWapper()
						.selectByconversionName(createBean.getBillName()).get(0);
				List<couponconversioncode> CouponConversionCodes = new couponconversioncodeWapper().selectByConversionId(bill.getConversionId());
				
				Logger.verifyEquals(createBean.getGenerateQuantity(), CouponConversionCodes.size(), "验证数据CouponConversionCode中生成相应记录");
				
				ConversionCouponBean conversionCouponBean = CouponServiceCallServiceV2.setConversionCouponBean(userId,CouponConversionCodes.get(0).getConversionCode());
				
				platformcouponCode = CouponServiceCallServiceV2.ConversionCoupon(conversionCouponBean).getCouponCodes().get(0);
			} else {
				platformcouponCode = CouponServiceCallServiceV2.receiveCouponInfo(couponbatchs.get(0).getBatchCode(),
						userId);

			}
		}

		// 商家优惠券
		String sellerCouponCode = null;
		if (couponBatchBean != null) {
			
			String batchCode1 = CouponServiceMCallServiceV2.SellerCreateBatch(couponBatchBean).getBatchCode();
			sellerCouponCode = CouponServiceCallServiceV2.receiveCouponInfo(batchCode1, userId);
			shoppingInfo = CouponServiceCallServiceV2.setDefaultShoppingInfo(userId, couponBatchBean.getSellerId(),platformcouponCode,
					sellerCouponCode);
		}
		else {
			shoppingInfo = CouponServiceCallServiceV2.setDefaultShoppingInfo(userId,platformcouponCode,
					sellerCouponCode);
		}
		Thread.sleep(3000);

		return shoppingInfo;
	}

	private void verifyReturn() {
		Logger.verifyEquals("0", checkcouponsCall.getStatusCode1(), "验证返回Code");
		Logger.verifyEquals("操作成功！", checkcouponsCall.getMessage(), "验证返回Message");

		CheckCouponsData returnData = checkcouponsCall.getData();
		Logger.verifyEquals(true, returnData.isIsSuccess(), "验证返回IsSuccess");

		List<CouponProducts> couponProductsList = returnData.getCouponProductsList();

		ShoppingInfo shoppingInfo = checkcouponsBean.getShoppingInfo();

		List<SellerOrderInfo> sellerOrderInfoList = shoppingInfo.getSellerOrderInfos();

		for (CouponProducts couponProducts : couponProductsList) {
			CouponInfo couponInfo = couponProducts.getCouponInfo();
			List<ProductInfo> productInfos = couponProducts.getProducts();

			// 验证商家优惠券的有效性
			if (couponInfo.getSellerId() != 0 ) {
				int sellerId = couponInfo.getSellerId();
				SellerOrderInfo sellerOrderInfo = getSellerOrderInfoBySellerId(sellerOrderInfoList, sellerId);

				if (sellerOrderInfo.getCouponCode() != null && !sellerOrderInfo.getCouponCode().equals("")) {
					verifyCouponInfo(sellerOrderInfo.getCouponCode(), couponInfo);
				}

				// verifyProductInfo(sellerOrderInfo.getOrderInfos().get(0).getProductInfos(),
				// productInfos);
			} else {
				// 验证平台优惠券
				verifyCouponInfo(shoppingInfo.getPlatformCouponCode(), couponInfo);
			}

		}
	}

	SellerOrderInfo getSellerOrderInfoBySellerId(List<SellerOrderInfo> sellerOrderInfoList, int sellerId) {
		for (SellerOrderInfo sellerOrderInfo : sellerOrderInfoList) {
			if (sellerOrderInfo.getSellerId() == sellerId) {
				return sellerOrderInfo;
			}
		}
		return null;
	}

	private void verifyCouponInfo(String couponCode, CouponInfo couponInfo) {
		Logger.comment("验证优惠券couponCode=" + couponCode + "相关信息");
		Map result = new couponWapper().selectCouponInfoByCouponCode(couponCode).get(0);

		Logger.verifyEquals(result.get("CouponName"), couponInfo.getCouponName(), "验证优惠券sCouponName与数据库相同");

		Logger.verifyEquals(true, isDateEqual(result.get("MinOrderValue"), couponInfo.getMeetAmount()),
				"验证优惠券MeetAmount与数据库相同");
		Logger.verifyEquals(true, isDateEqual(result.get("CouponValue"), couponInfo.getDeductionAmount()),
				"验证优惠券DeductionAmount与数据库相同");

		Logger.verifyEquals(true, isDateEqual(result.get("ValidStart").toString(), couponInfo.getStartTime()),
				"验证优惠券StartTime与数据库相同");
		Logger.verifyEquals(true, isDateEqual(result.get("ValidEnd").toString(), couponInfo.getEndTime()),
				"验证优惠券EndTime与数据库相同");
//		Logger.verifyEquals(result.get("iUserType"), couponInfo.getUserTypeInfo(), "验证优惠券UserTypeInfo与数据库相同-userTypeInfo目前未有赋值，都是返回默认0，已知bug，重构时会修改");
		Logger.verifyEquals(result.get("SellerId"), couponInfo.getSellerId(), "验证优惠券SellerIds与数据库相同");
		List<couponusecondition> couponsequences=new couponuseconditionWapper().selectByBatchId(Integer.parseInt(result.get("BatchId").toString()));
		if(couponsequences.size()>0)
		{
			couponusecondition couponsequence=couponsequences.get(0);
			if(Integer.parseInt(couponsequence.getConditionValue())==1)
			{
			 Logger.verifyEquals(couponsequence.getConditionValue(),couponInfo.getProductCategories(),
					 "验证优惠券数据库中ConditionValue包含商品指定ProductCategories");
			}
			else if(Integer.parseInt(couponsequence.getConditionValue())==2)
			{
				 Logger.verifyEquals(couponsequence.getConditionValue(),couponInfo.getSpecificProducts(),
						 "验证优惠券数据库中ConditionValue包含商品指定getSpecificProducts");
			}
			else if(Integer.parseInt(couponsequence.getConditionValue())==3)
			{
				 Logger.verifyEquals(couponsequence.getConditionValue(),couponInfo.getProductBrands(),
						 "验证优惠券数据库中ConditionValue包含商品指定getProductBrands");
			}
			else if(Integer.parseInt(couponsequence.getConditionValue())==4)
			{
				 Logger.verifyEquals(couponsequence.getConditionValue(),couponInfo.getActivityIds(),
						 "验证优惠券数据库中ConditionValue包含商品指定getActivityIds");
			}
			else if(Integer.parseInt(couponsequence.getConditionValue())==5)
			{
				 Logger.verifyEquals(couponsequence.getConditionValue(),couponInfo.getUsePlatforms(),
						 "验证优惠券数据库中ConditionValue包含商品指定getUsePlatforms");
			}
			else if(Integer.parseInt(couponsequence.getConditionValue())==6)
			{
				 Logger.verifyEquals(couponsequence.getConditionValue(),couponInfo.getCountrys(),
						 "验证优惠券数据库中ConditionValue包含商品指定getCountrys");
			}
		}
		else
		{
			Logger.verifyEquals("", couponInfo.getProductCategories(),
			"验证优惠券数据库中ProductCategories包含商品指定ProductCategories");
			Logger.verifyEquals("", couponInfo.getSpecificProducts(),
					"验证优惠券数据库中SpecificProducts包含商品指定SpecificProducts");
			Logger.verifyEquals("", couponInfo.getProductBrands(),
					"验证优惠券数据库中ProductBrands包含商品指定ProductBrands");
			Logger.verifyEquals("", couponInfo.getActivityIds(),
					"验证优惠券数据库中ActivityIds与包含商品指定ActivityIds");
			Logger.verifyEquals("",couponInfo.getCountrys(),
							 "验证优惠券数据库中ConditionValue包含商品指定getCountrys");
		}
		Logger.verifyEquals(result.get("UsePlatformIds").toString(), couponInfo.getUsePlatforms(),
				"验证优惠券数据库中UsePlatforms包含商品指定UsePlatforms");
				
//		Logger.verifyEquals(true, isContain(result.get("sProductCategories"), couponInfo.getProductCategories()),
//				"验证优惠券数据库中ProductCategories包含商品指定ProductCategories");
//		Logger.verifyEquals(true, isContain(result.get("sSpecificProducts"), couponInfo.getSpecificProducts()),
//				"验证优惠券数据库中SpecificProducts包含商品指定SpecificProducts");
//		Logger.verifyEquals(true, isContain(result.get("sProductBrands"), couponInfo.getProductBrands()),
//				"验证优惠券数据库中ProductBrands包含商品指定ProductBrands");
//		Logger.verifyEquals(true, isContain(result.get("sActivityIds"), couponInfo.getActivityIds()),
//				"验证优惠券数据库中ActivityIds与包含商品指定ActivityIds");
//		Logger.verifyEquals(true, isContain(result.get("sUsePlatforms"), couponInfo.getUsePlatforms()),
//				"验证优惠券数据库中UsePlatforms包含商品指定UsePlatforms");
		
		Logger.verifyEquals(Integer.parseInt(result.get("UseConditionType").toString()), couponInfo.getProductLimitType(),
				"验证返回字段productLimitType与couponbatch表中UseConditionType一致");


	}

	private void verifyProductInfo(List<ProductInfo> src, List<ProductInfo> des) {
		Logger.comment("验证返回的ProductInfoList信息");
		Logger.verifyEquals(src.size(), des.size(), "验证ProductInfo数目相同");

		for (int i = 0; i < src.size(); i++) {
			Logger.verifyEquals(src.get(i).getProductCode(), des.get(i).getProductCode(),
					"验证ProductInfo中ProductCode与传入一致");
			Logger.verifyEquals(src.get(i).getActivityId(), des.get(i).getActivityId(),
					"验证ProductInfo中ActivityId与传入一致");
			Logger.verifyEquals(src.get(i).isNotAllowUsePlatformCoupon(), des.get(i).isNotAllowUsePlatformCoupon(),
					"验证ProductInfo中isNotAllowUsePlatformCoupon与传入一致");
			Logger.verifyEquals(src.get(i).isNotAllowUseSellerCoupon(), des.get(i).isNotAllowUseSellerCoupon(),
					"验证ProductInfo中isNotAllowUseSellerCoupon与传入一致");
			Logger.verifyEquals(src.get(i).getBrandId(), des.get(i).getBrandId(), "验证ProductInfo中BrandId与传入一致");
			Logger.verifyEquals(src.get(i).getCategoryId(), des.get(i).getCategoryId(),
					"验证ProductInfo中CategoryId与传入一致");
			Logger.verifyEquals(src.get(i).getProductQuantity(), des.get(i).getProductQuantity(),
					"验证ProductInfo中ProductQuantity与传入一致");
			Logger.verifyEquals(src.get(i).getProductPrice(), des.get(i).getProductPrice(),
					"验证ProductInfo中ProductPrice与传入一致");
			Logger.verifyEquals(src.get(i).getCountryId(), des.get(i).getCountryId(),
					"验证ProductInfo中CountryId与传入一致");
//			Logger.verifyEquals(src.get(i).getSellerId(), des.get(i).getSellerId(),
//					"验证ProductInfo中SellerId与传入一致");
			
		}
	}

	/**
	 * 验证src中的串包含dec
	 * 
	 * @param src
	 * @param des
	 * @return
	 */
	private boolean isContain(Object src, String des) {
		if (src == null) {
			return true;
		}
		String srcArray[] = src.toString().split(",");
		String desArray[] = des.split(",");

		for (String str : desArray) {
			if (!isStrInArray(srcArray, str))
				return false;
		}
		return true;
	}

	private boolean isStrInArray(String[] src, String des) {
		for (String str : src) {
			if (str.equals(des))
				return true;
		}
		return false;
	}

	private boolean isDateEqual(String str1, String str2) {
		str1 = str1.substring(0, 18);
		str2 = str2.substring(0, 18).replace("T", " ");
		return str1.equals(str2);
	}

	private boolean isDateEqual(Object str1, BigDecimal str2) {
		BigDecimal str3 = new BigDecimal(Float.parseFloat(str1.toString()));
		return str3.compareTo(str2) == 0;
	}

	private SellerOrderInfo generateSellerOrderInfoBean() {
		SellerOrderInfo sellerOrderInfo = new SellerOrderInfo();

		// 卖家Id
		int sellerId = Integer.parseInt(EnvSetup.getData("couponSellerId"));
		sellerOrderInfo.setSellerId(sellerId);

		// 第一个OrderInfo
		OrderInfo orderInfo1 = new OrderInfo();
		ProductInfo productInfo1 = new ProductInfo();

		String productCode1 = TestDataManager.getRandomNum(36);
		productInfo1.setProductCode(productCode1);
		productInfo1.setActivityId(0);
		productInfo1.setBrandId(2111);
		productInfo1.setCategoryId(3111);
		productInfo1.setProductQuantity(1);
		productInfo1.setProductPrice(new BigDecimal(1000));

		List<ProductInfo> productInfos1 = new ArrayList<ProductInfo>();
		productInfos1.add(productInfo1);
		orderInfo1.setProductInfos(productInfos1);

		// 第二个orderinfo
		OrderInfo orderInfo2 = new OrderInfo();
		ProductInfo productInfo2 = new ProductInfo();

		String productCode2 = TestDataManager.getRandomNum(36);
		productInfo2.setProductCode(productCode2);
		productInfo2.setActivityId(0);
		productInfo2.setBrandId(2111);
		productInfo2.setCategoryId(3111);
		productInfo2.setProductQuantity(2);
		productInfo2.setProductPrice(new BigDecimal(1000));

		List<ProductInfo> productInfos2 = new ArrayList<ProductInfo>();
		productInfos2.add(productInfo2);
		orderInfo2.setProductInfos(productInfos2);

		List<OrderInfo> orderInfos = new ArrayList<OrderInfo>();

		orderInfos.add(orderInfo1);
		orderInfos.add(orderInfo2);

		sellerOrderInfo.setOrderInfos(orderInfos);

		return sellerOrderInfo;
	}

	private OrderInfo generateOrderInfoBean() {
		// OrderInfo
		OrderInfo orderInfo1 = new OrderInfo();
		ProductInfo productInfo1 = new ProductInfo();

		String productCode1 = TestDataManager.getRandomNum(36);
		productInfo1.setProductCode(productCode1);
		productInfo1.setActivityId(0);
		productInfo1.setBrandId(2111);
		productInfo1.setCategoryId(3111);
		productInfo1.setProductQuantity(1);
		productInfo1.setProductPrice(new BigDecimal(1000));

		List<ProductInfo> productInfos1 = new ArrayList<ProductInfo>();
		productInfos1.add(productInfo1);
		orderInfo1.setProductInfos(productInfos1);

		return orderInfo1;
	}
}
